package com.cetool.autocms.controller.tradesequence;

import com.cetool.autocms.annotation.TokenAnnotation;
import com.cetool.autocms.common.PageRequest;
import com.cetool.autocms.enumeration.OperateEnum;
import com.cetool.autocms.pojo.dto.tradesequence.NoticeDataListDTO;
import com.cetool.autocms.pojo.request.tradesequence.QueryNoticeDataRequest;
import com.cetool.autocms.pojo.request.tradesequence.UpdateNoticeDataRequest;
import com.cetool.autocms.service.tradesequence.NoticeDataService;
import com.github.pagehelper.PageSerializable;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * 公告数据管理
 *
 * @author 戴越
 * @date 2021/12/6
 */
@RestController
@RequestMapping("/notice")
@Api(tags = "公告数据管理")
public class NoticeDataController {
    /**
     * 注入公告数据管理服务
     */
    @Autowired
    private NoticeDataService noticeDataService;

    /**
     * 分页查询公告数据列表
     *
     * @param request 分页查询公告数据请求实体
     * @return 公告数据信息分页列表
     * @author 戴越
     * @date 2021/12/6
     */
    @TokenAnnotation
    @PostMapping("/listPageNoticeData")
    @ApiOperation(value = "分页查询公告数据列表")
    public PageSerializable<NoticeDataListDTO> listPageNoticeData(@RequestBody PageRequest<QueryNoticeDataRequest> request) {
        return noticeDataService.listPageNoticeData(request);
    }

    /**
     * 修改公告数据
     *
     * @param request 修改公告数据请求实体
     * @return 操作信息
     * @author 戴越
     * @date 2021/12/7
     */
    @TokenAnnotation
    @PostMapping("/updateNoticeData")
    @ApiOperation(value = "修改公告数据")
    public OperateEnum updateNoticeData(@Valid @RequestBody UpdateNoticeDataRequest request) {
        return noticeDataService.updateNoticeData(request);
    }
}
